package models.sys;

import javax.persistence.Column;
import javax.persistence.Entity;

import play.db.jpa.Model;

@Entity(name = "u_role")
public class Role extends Model {

    @Column(unique = true)
    public String name;

    public static Role getOrCreate(String name) {
        Role role = Role.find("byName", name).first();
        if (role != null) {
            return role;
        }
        role = new Role();
        role.name = name;
        role.save();
        return role;
    }
}
